# -*- mode: python; coding: utf-8; -*-
##--------------------------------------------------------------------------##
##
## Copyright (C) 1998-2003 Markus Oberhumer <markus@oberhumer.com>
## Copyright (C) 2003 Mt. Hood Playing Card Co.
## Copyright (C) 2005-2010 Skomoroh <skomoroh@users.sourceforge.net>
## Copyright (C) 2010-2013 Jeremy Austin-Bardo <tjaustinbardo@gmail.com>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##--------------------------------------------------------------------------##
"""
Casket Stacks
"""

from ..utillib.misc import kwdefault
from .. import pilelib as stack
from .. import helpstrings as hs
from .. import hint


class Casket_Hint(hint.SortHeldCautiousHint):

    @property
    def _to_piles(self):
        """
        _to_piles() -> seq

        Rank should be found from this pile top card. Default Game.s.xwastes.
        """
        return self._stacks['set']['wastes'][:-1]

    @property
    def _from_pile(self):
        """
        _from_pile() -> seq

        Rank should be found from this pile top card. Default Game.s.waste.
        """
        return self._stacks['set']['wastes'][-1]


class Well_RowStack(stack.SS_RowStack):
    _BOTTOM_IMAGE_ = 'shade'

    def __init__(self, x, y, game, **cap):
        """
        __init__(x, y, game[, dir=1, mod=13, max_move=1]) -> None

        :Parameters:
          x : int
            left x-coordinate.

          y : int
            top y-coordinate.

          game : pysollib.game.Game
            current Game.

        seealso::
          `pysollib.stackcaps` with details of *capability* keywords.
        """
        kwdefault(cap, dir=1, mod=13, max_move=1)
        super(Well_RowStack, self).__init__(x, y, game, **cap)


class Casket_RowStack(stack.GapNotFromBuildMethod, stack.SS_RowStack):
    _BOTTOM_IMAGE_ = 'shade'

    @property
    def _fromstacks(self):
        """
        _fromstacks() -> bool

        Cards except from reserves piles may build when gap.

        :Parameters:
          from_stack : stack.Stack
            pile that held sequence.
          cards : tuple
            sequence.
        :returns: sequence accepted?
        """
        return self.game.s['reserves']